﻿#light

open Printf
open Microsoft.FSharp.Compatibility.OCaml

let save_file s = 
    printf "Saving definitions to %s.\n" s;
    let file = open_out s;
    Hashtbl.iter (fun n d -> fprintf file "Def %s = %s\n" n (string_of_fct d)) defs;
    close_out file;
    T
    
let rec load_file s = 
  printf "Loading definitions from %s.\n" s;
  let f = open_in s in
  try
    while true do
     let str = input_line f in str;
      if   ((str.Contatins '#' ) or (String.length str = 0) )then
       begin
        print_string(""); 
      end
      else
       begin
        print_string (str^"\n"); 
        print_expr (eval_cmd (cmd lexer (Lexing.from_string (str^"\n"))) )
      end
    done;
    "File loaded successfully"
  with | End_of_file -> close_in f; "File loaded successfully" | _ -> "ERROR"

